<?php
echo validation_errors();
$form = array(
    'id'    => 'form-newsletter',
    'class' => 'ut-form'
);
echo form_open('newsletter/send_newsletter',$form);
echo form_fieldset();
echo '<ul>';
if(isset($lista))
    $users = '<li>'.form_radio('lista','lall',TRUE).form_label('Do wszystkich')
             .'<li>'.form_radio('lista','sall',FALSE).form_label('Do wybranych:','selected[]').form_multiselect('selected[]',$lista,set_value('selected[]'),'id="selected" disabled').'</li>';
else
    $users = '<li>'.form_label('Do wszystkich');
echo $users;
echo '<li>'.form_label('Tytuł:','title').form_input(array('name'=>'title','placeholder'=>'Wpisz tytuł newslettera','class'=>'large'),set_value('title')).'</li>';
echo '<li>'.form_label('Treść:','content').'<textarea class="ckeditor" name="content">'.set_value('content').'</textarea></li>';
echo '</ul>';
echo form_fieldset_close();
echo '<p class="clear">'.form_submit('send','Wyślij newsletter','class="btn-primary btn-large"').'</p>';
echo form_close();
?>
<script>
$(function(){
    $('input:radio[name=lista]').on('change',function(){
        if($(this).val()=='sall')
            $('#selected').removeProp('disabled');
        else
            $('#selected').prop('disabled',true);
    });
});
</script>
